class Solution(object):
    def diStringMatch(self, s):
        """
        :type s: str
        :rtype: List[int]
        """
        n = len(s) + 1
        out = [0] * n
        nums = [i for i in range(n)]
        left_index = 0
        right_index = n - 1
        for i in range(n - 1):
            if s[i] == 'I':
                out[i] = nums[left_index]
                left_index += 1
            else:
                out[i] = nums[right_index]
                right_index -= 1
        out[-1] = nums[left_index]
        return out



data = Solution()
s = "DDI"
print(data.diStringMatch(s))
